package org.pro.test;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

	@RequestMapping("/me1")
	public Authentication queryMe() {
		return SecurityContextHolder.getContext().getAuthentication();
	}
	@RequestMapping("/me2")
	public Authentication queryMe2(Authentication authentication) {
		return authentication;
	}
	
	@RequestMapping("/meUser")
	public UserDetails queryMeUser(@AuthenticationPrincipal UserDetails authentication) {
		return authentication;
	}
}
